package com.yjz.demo.log;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.yjz.demo.R;
import com.yjz.log.JLog;
import com.yjz.log.manager.JLogManager;
import com.yjz.log.print.view.ViewPrinter;

/**
 * 作用 : JLog用法展示
 * 作者 : yjz
 * 时间 : 2024/9/14 16:05
 */
public class JLogDemoActivity extends AppCompatActivity {

    private ViewPrinter viewPrinter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ylog);

        // 添加log的悬浮
        viewPrinter = new ViewPrinter(this);
        JLogManager.getInstance().addPrinter(viewPrinter);
        viewPrinter.getViewProvider().showFloatingView();

        // 正常打印日志
        findViewById(R.id.normal_log_btn).setOnClickListener(view -> JLog.e("yjz is very good!"));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        viewPrinter.getViewProvider().closeFloatingView();
    }
}
